﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FormaBedoboNS
{
    /// <summary>
    /// Az alkalmazás beállításait kezelő windows form
    /// </summary>
    public partial class BeallitasokForm : Form, IDisposable
    {
        /// <summary>
        /// A beállító ablak eseménykezelője
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="s"></param>
        public delegate void BeallitasokFormAblakEsemeny(object sender, string s);
        /// <summary>
        /// 
        /// </summary>
        public BeallitasokFormAblakEsemeny beallitoAblakEsemeny;

        /// <summary>
        /// dtor
        /// </summary>
        ~BeallitasokForm()
        {
            Console.WriteLine("BeállításForm destroly");
        }
        /// <summary>
        /// ctor
        /// </summary>
        public BeallitasokForm()
        {
            InitializeComponent();
            dataGridView1.Columns["level1DataGridViewTextBoxColumn"].DefaultCellStyle.Format = "mm':'ss':'ff";
            dataGridView1.Columns["level2DataGridViewTextBoxColumn"].DefaultCellStyle.Format = "mm':'ss':'ff";
            dataGridView1.Columns["level3DataGridViewTextBoxColumn"].DefaultCellStyle.Format = "mm':'ss':'ff";
            dataGridView1.Columns["level4DataGridViewTextBoxColumn"].DefaultCellStyle.Format = "mm':'ss':'ff";
            dataGridView1.Columns["level5DataGridViewTextBoxColumn"].DefaultCellStyle.Format = "mm':'ss':'ff";

        }

        /// <summary>
        /// bezárás button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void closeButton_Click(object sender, EventArgs e)
        {
            this.Close();   
        }

        /// <summary>
        /// form betöltésekor
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BeallitasForm_Load(object sender, EventArgs e)
        {
            Text = AppSettings.getString("settings");
            closeButton.Text = AppSettings.getString("close");
            button2.Text = AppSettings.getString("generate modells");
            button1.Text = AppSettings.getString("save settings");
            dataGridView1.Columns[0].HeaderText = AppSettings.getString("username");
            dataGridView1.Columns[1].HeaderText = AppSettings.getString("szint1");
            dataGridView1.Columns[2].HeaderText = AppSettings.getString("szint2");
            dataGridView1.Columns[3].HeaderText = AppSettings.getString("szint3");
            dataGridView1.Columns[4].HeaderText = AppSettings.getString("szint4");
            dataGridView1.Columns[5].HeaderText = AppSettings.getString("szint5");
        }


 
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BeallitasForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            beallitoAblakEsemeny(this, "bezárt");
        }


        /// <summary>
        /// save to HDD button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            AppSettings.adatKiiras();
        }

        /// <summary>
        /// Modellek generálása
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            AppSettings.instance.ContentBuild();
        }


        private void dataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs e)
        {
            Console.WriteLine(e.Exception);
            MessageBox.Show(AppSettings.getString("usernamehiba"), AppSettings.getString("error"));
        }



        

    }
}
